package com.applink.sell_proof;

import android.os.Bundle;
import android.widget.CompoundButton;

import com.applink.sell_proof.fragment.UserSettingFragment;
import com.applink.sell_proof.fragment.adapter.BaseFragmentPagerAdapter;
import com.applink.sell_proof.fragment.adapter.CustomerServiceFragmentPagerAdapter;
import com.applink.sell_proof.util.Utility;

public class CustomerServiceActivity extends BasePagerActivity {

	protected BaseFragmentPagerAdapter mFragmentAdapter;

	@Override
	protected void onCreate(Bundle saveInstanceState) {
		super.onCreate(saveInstanceState);
		setTitle(getString(R.string.customer_service));
	}

	@Override
	protected BaseFragmentPagerAdapter getFragmentPagerAdapter() {
		// TODO Auto-generated method stub
		if (mFragmentAdapter == null) {
			mFragmentAdapter = new CustomerServiceFragmentPagerAdapter(
					getSupportFragmentManager());
		}
		return mFragmentAdapter;

	}

	@Override
	protected void onResume() {
		super.onResume();
		int checkState = Utility.checkTimeValidation();
		switch (checkState) {
		case 0:
			Utility.showAlertDialogLogout(this,
					android.R.drawable.ic_dialog_alert,
					Utility.messageServerTimeOut, Utility.titleServerTimeOut,
					CustomerServiceActivity.this);
			break;
		case 1:
			Utility.showAlertDialogLogout(this,
					android.R.drawable.ic_dialog_alert,
					Utility.messageLocalTimeOut, Utility.titleLocalTimeOut,
					CustomerServiceActivity.this);
			break;

		default:
			break;
		}
	}

	@Override
	protected int getDefaultPagerIndex() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void setSelectedTab() {
		((CompoundButton) findViewById(R.id.custservice_tab)).setChecked(true);
	}

	@Override
	public int getActivityIndex() {
		return BasePagerActivity.SUPPORT_ACTIVITY;
	}

	public void updateUserProfile() {
		UserSettingFragment userProfile = (UserSettingFragment) mFragmentAdapter
				.getFragmentAt(1);
		userProfile.SetUserSettingInfo();
	}

}
